<#include
        "../../common/com.html"  /> <@layout>
<!-- ace styles -->
<link rel="stylesheet" href="${ctx}/static/assets/css/ace.min.css" />
<link rel="stylesheet" href="${ctx}/static/kindeditor/themes/default/default.css" />

<script charset="utf-8" src="${ctx}/static/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="${ctx}/static/kindeditor/lang/zh_CN.js"></script>
<script charset="utf-8" src="${ctx}/static/kindeditor/plugins/code/prettify.js"></script>

<script type="text/javascript">
    /**
     * 保存新增的模型数据
     */
    var editor;

    var options = {
        cssPath : '/css/index.css',
        filterMode : true
    };
    function saveModel() {
        if(Validator.Validate(document.getElementById('form1'))){
        } else {
            return;
        }
//       var m=$("#nr").val();
//        m = m.replace(/(\t)/g, "");
//       m = m.replace(/(\n)/g, "");
//        alert(m);
////        $("#xmjj").attr("value",m);
// 同步数据后可以直接取得textarea的value
        var id=document.getElementById("id").value;
        url = '';
        if(id==""){
            url = '${ctx}/wxResource/save';
        }     else{
            url = '${ctx}/wxResource/update';
        }
        $('#form1').form('submit', {
            url : url,
            onSubmit : function() {
                return $(this).form('validate');
            },
            success : function(data) {
                alert(data);
                parent.location.reload();
            }
        });

    }
</script>
<body>
<div class="page-header" style="height: 20px">

    <div class="row-fluid">
        <div class="span12">
            <!-- PAGE CONTENT BEGINS -->
            <div class="tabbable tabs-left">
                <form class="form-horizontal"  id="form1" method="post" >
                    <table class="table table-condensed table-bordered">
                        <input type="hidden" name="id" id="id">
                        <tbody>

                        <tr class="info">
                            <td>
                                标题：
                            </td>
                            <td >
                                <input type="text" name="bt" id="bt" style="min-height: 24px;"   dataType="Require" msg="请输入标题" >
                            </td>

                        </tr>

                        <tr class="info">
                            <td>
                                内容：
                            </td>
                            <td  >
                                <textarea class="span12"  id="nr" name="nr" style="width:95%;height:400px;visibility:hidden;">${(nr)!}</textarea>
                            </td>

                        </tr>
                        <tr class="info">
                            <td colspan="2" style="text-align: center">
                                <a href="#"  class="btn btn-info btn-small" onclick="saveModel()"   >确定 </a>
                                &nbsp; &nbsp;&nbsp;&nbsp;
                                <a href="#"  class="btn btn-danger btn-small bigger-110"  onclick="parent.closeDialog();"  >取消 </a>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </form>
            </div>

        </div>

    </div>
</div>

</body>
<script src="${ctx}/static/assets/js/bootstrap-wysiwyg.min.js"></script>


<script>
    KindEditor.ready(function(K) {
        K.each({
            'plug-align' : {
                name : '对齐方式',
                method : {
                    'justifyleft' : '左对齐',
                    'justifycenter' : '居中对齐',
                    'justifyright' : '右对齐'
                }
            },
            'plug-order' : {
                name : '编号',
                method : {
                    'insertorderedlist' : '数字编号',
                    'insertunorderedlist' : '项目编号'
                }
            },
            'plug-indent' : {
                name : '缩进',
                method : {
                    'indent' : '向右缩进',
                    'outdent' : '向左缩进'
                }
            }
        },function( pluginName, pluginData ){
            var lang = {};
            lang[pluginName] = pluginData.name;
            KindEditor.lang( lang );
            KindEditor.plugin( pluginName, function(K) {
                var self = this;
                self.clickToolbar( pluginName, function() {
                    var menu = self.createMenu({
                        name : pluginName,
                        width : pluginData.width || 100
                    });
                    K.each( pluginData.method, function( i, v ){
                        menu.addItem({
                            title : v,
                            checked : false,
                            iconClass : pluginName+'-'+i,
                            click : function() {
                                self.exec(i).hideMenu();
                            }
                        });
                    })
                });
            });
        });
        editor =  K.create('#nr', {
            cssPath : '${ctx}/static/kindeditor/plugins/code/prettify.css',
            uploadJson : '${ctx}/uploadWxfile/upload/',
            fileManagerJson : '${ctx}/uploadWxfile/manageImg',
            allowFileManager : true,
            themeType : 'default',
            filterMode : true,
            items :[
                'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'paste',
                'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent',
                'clearhtml', 'quickformat', 'selectall', '|',
                'formatblock', 'fontname', 'fontsize', '|','/', 'forecolor', 'hilitecolor', 'bold',
                'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|',
                'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
                'anchor', 'link', 'unlink', '|', '|', 'image', 'multiimage'
            ] ,
            afterBlur:function(){this.sync(); }
        });

    });
</script>
<script>

    <#list newlist as m>
            document.getElementById("id").value  = '${(m.id)!}';
    document.getElementById("bt").value  =  '${(m.bt)!}';

    </#list>

</script>
</@layout>

